package com.huak.boot;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author LR2SD
 * @description
 * @date 2019-03-30 10:14
 */
public class SpringApplicationEventBootstrap {

    public static void main(String [] args){
        AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext();
        context.addApplicationListener(event -> {
            System.out.println("监听到事件："+event);
        });
        //容器开启
        context.refresh();

        context.publishEvent("hello");
        context.publishEvent("2019");
        context.publishEvent(new ApplicationEvent("lr2sd") {
        });

        //容器关闭
        context.close();


    }

}
